# Maintainer: Greg Williamson <cheeseboy16@gmail.com>

_realname=alure
pkgbase="mingw-w64-${_realname}"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.2
pkgrel=1
pkgdesc='Utility library to help manage common tasks with OpenAL applications (mingw-w64)'
arch=('any')
url='https://kcat.strangesoft.net/alure.html'
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-openal")
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake" 
             "${MINGW_PACKAGE_PREFIX}-libsndfile" 
             "${MINGW_PACKAGE_PREFIX}-libvorbis" 
             "${MINGW_PACKAGE_PREFIX}-flac" 
             "${MINGW_PACKAGE_PREFIX}-mpg123" 
             "${MINGW_PACKAGE_PREFIX}-dumb" 
             "${MINGW_PACKAGE_PREFIX}-fluidsynth")
optdepends=("${MINGW_PACKAGE_PREFIX}-libsndfile: for uncompressed audio support"
            "${MINGW_PACKAGE_PREFIX}-libvorbis: for OGG Vorbis support"
            "${MINGW_PACKAGE_PREFIX}-flac: for FLAC support"
            "${MINGW_PACKAGE_PREFIX}-mpg123: for MPEG support"
            "${MINGW_PACKAGE_PREFIX}-dumb: for IT, XM, S3M and MOD support"
            "${MINGW_PACKAGE_PREFIX}-fluidsynth: for SoundFont 2 support")
source=("https://kcat.strangesoft.net/alure-releases/${_realname}-${pkgver}.tar.bz2"
        build.patch)
sha256sums=('465e6adae68927be3a023903764662d64404e40c4c152d160e3a8838b1d70f71'
            '21029cfc8900b8270f6c7a79235e09a05d45d0b03b221d9d856a27e98cc0931b')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i "${srcdir}/build.patch"
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -G "MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
    ../${_realname}-${pkgver}
  
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"

  make DESTDIR="${pkgdir}" install

  install -Dm0644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
